local skel = fk.CreateSkill {
  name = "emo__muwang",
  tags = {Skill.Compulsory}
}

skel:addEffect(fk.EventPhaseChanging, {
  anim_type = "negative",
  can_trigger = function (self, event, target, player, data)
    return player:hasSkill(skel.name) and target == player and #player:getPile("emo__deduce") > 0
    and (data.phase == Player.Draw or data.phase == Player.Discard)
  end,
  on_use = function (self, event, target, player, data)
    data.skipped = true
  end,
})

skel:addEffect(fk.TurnEnd, {
  anim_type = "defensive",
  can_trigger = function (self, event, target, player, data)
    if player:hasSkill(skel.name) and target == player and player:isWounded() then
      local phases = player.room.logic:getEventsOfScope(GameEvent.Phase, 1, function (e)
        return e.data.phase == Player.Discard and e.end_id ~= nil
      end, Player.HistoryTurn)
      if #phases == 0 then return true end
      return #player.room.logic:getEventsOfScope(GameEvent.MoveCards, 1, function(e)
      for _, move in ipairs(e.data) do
        local phase_check = false
        for _, phase_event in ipairs(phases) do
          if e.id > phase_event.id and e.id < phase_event.end_id then
            phase_check = true
            break
          end
        end
        if not phase_check then return false end
        if move.from == player then
          for _, info in ipairs(move.moveInfo) do
            if info.fromArea == Card.PlayerHand then
              return true
            end
          end
        end
      end
      return false
    end, Player.HistoryTurn) == 0
    end
  end,
  on_use = function (self, event, target, player, data)
    player.room:recover { num = 1, skillName = skel.name, who = player, recoverBy = player }
  end,
})



Fk:loadTranslationTable{
  ["emo__muwang"] = "暮往",
  [":emo__muwang"] = "锁定技，若你有“绎”则跳过摸牌和弃牌阶段；回合结束时，若你没有于弃牌阶段弃置手牌，你恢复一点体力。",
}

return skel
